import pytest
import os
import sys
import logging
from utils.send_feishu_msg import send_feishu_message

if __name__ == "__main__":
    print(sys.argv)
    if len(sys.argv) == 2:
        if(sys.argv[1] == 'test'):    #测试环境
            pass
            os.environ["EVN"] = "test"
        elif(sys.argv[1] == 'prod'):   #生产环境
            #os.environ是当前的环境变量
            os.environ["URL"] = "http://192.168.10.141/api/cloud-api"
            os.environ["DB"] = str({
                "host": "192.168.10.141",
                "port": 3306,
                "user": "root",
                "passwd": "123456",
                "database": "xingyun"
            })
            os.environ["EVN"] = "prod"
        else:
            logging.error("1请传入正确的执行命令：python run.py test 或者python run.py prod")
    else:
        logging.error("2请传入正确的执行命令：python run.py test 或者python run.py prod")



    pytest.main(["-vs", "./testcases/test_runner5-7.py","--alluredir" , "./report/json_report" , "--clean-alluredir"])
    os.system("allure generate ./report/json_report -o ./report/html_report --clean")

    #飞书发送测试报告
    send_feishu_message()